def insertionSort(arr):
    n = len(arr)
    count = 0
    for i in range(1, n):
        key = arr[i]
        j = i - 1
        while j >= 0 and arr[j] > key:
            arr[j + 1] = arr[j]
            j -= 1
            count += 1
        arr[j + 1] = key
    print(f"运行次数: {count}")
    return arr

arr = [5, 3, 4, 6, 2]
sorted_arr = insertionSort(arr)
print(sorted_arr)